package com.springboot.distributed.transaction.util;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.support.DefaultTransactionStatus;

import lombok.Data;

/**
 * 事务状态包装类
 *
 * @author supu
 * @date 2019-09-05 16:55
 **/
@Data
public class DefaultTransactionStatusWrapper {
    /**
     * 同一个线程可能有多个事务
     */
    private final List<DefaultTransactionStatus> transactionStatusList = new ArrayList<>();

    /**
     * 事务开始时间
     */
    private final long startTime;

    public DefaultTransactionStatusWrapper(DefaultTransactionStatus defaultTransactionStatus) {
        transactionStatusList.add(defaultTransactionStatus);
        startTime = System.currentTimeMillis();
    }
}
